package com.sthz.facepay.mapper;

import com.sthz.facepay.model.Interval;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface IntervalMapper {
    @Delete({
        "delete from st_interval",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into st_interval (id, cycle, ",
        "start_time, end_time)",
        "values (#{id,jdbcType=INTEGER}, #{cycle,jdbcType=VARCHAR}, ",
        "#{start_time,jdbcType=TIMESTAMP}, #{end_time,jdbcType=TIMESTAMP})"
    })
    int insert(Interval record);

    @InsertProvider(type=IntervalSqlProvider.class, method="insertSelective")
    int insertSelective(Interval record);

    @Select({
        "select",
        "id, cycle, start_time, end_time",
        "from st_interval",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="cycle", property="cycle", jdbcType=JdbcType.VARCHAR),
        @Result(column="start_time", property="start_time", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="end_time", property="end_time", jdbcType=JdbcType.TIMESTAMP)
    })
    Interval selectByPrimaryKey(Integer id);

    @UpdateProvider(type=IntervalSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Interval record);

    @Update({
        "update st_interval",
        "set cycle = #{cycle,jdbcType=VARCHAR},",
          "start_time = #{start_time,jdbcType=TIMESTAMP},",
          "end_time = #{end_time,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Interval record);
}